from locust import HttpUser, task, between
import random

class WebUser(HttpUser):
    wait_time = between(1, 3)  # 用户思考时间
    
    @task(10)
    def get_classes(self):
        # 获取班级列表，高频率操作
        self.client.get("/api/v1/classes?school_id=1")
    
    @task(5)
    def get_class_courses(self):
        # 获取班级课程表，中频率操作
        class_codes = ["23371101", "23371102", "23371103", "23371104"]
        self.client.get(f"/api/v1/classes/{random.choice(class_codes)}/courses")
    
    @task(1)
    def get_filters(self):
        # 获取筛选条件，低频率操作
        self.client.get("/api/v1/classes/filters?school_id=1")
    
    @task(3)
    def health_check(self):
        # 健康检查
        self.client.get("/health")
    
    @task(2)
    def cached_endpoint(self):
        # 测试缓存端点
        self.client.get("/demo/cached")
    
    @task(1)
    def monitoring(self):
        # 监控指标
        self.client.get("/monitoring/all")
